/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-08-19
 * Time: 12:39
 */

class MyThread1 extends Thread {
    @Override
    public void run() {
        while(true) {
            System.out.println("hello mythread!");
            try {
                Thread .sleep(500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

class MyRunnable1 implements Runnable {
    @Override
    public void run() {
        while(true) {
            System.out.println("hello mythread!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class ThreadDemo2 {
    public static void main(String[] args) {
        Thread t = new MyThread();
        t.start();
        while(true) {
            System.out.println("hello main!");
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }

//        Thread t = new Thread(new MyRunnable());
//        t.start();
//        while(true) {
//            System.out.println("hello main!");
//            try {
//                Thread.sleep(1000);
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }
//        }
    }
}
